package com.dapangdong.testdemo.config;

import org.springframework.context.ApplicationListener;
import org.springframework.data.redis.core.RedisKeyExpiredEvent;
import org.springframework.stereotype.Component;

/**
 * <p>
 *  监听RedisKeyExpiredEvent事件就可以拿到过期消息的Key，也就是延迟消息
 * </p>
 *
 * @author : yhd
 * @program: gulimall
 * @since : 2023-06-12 17:56
 */
@Component
public class MyRedisKeyExpiredEventListener implements ApplicationListener<RedisKeyExpiredEvent> {

    @Override
    public void onApplicationEvent(RedisKeyExpiredEvent event) {
        byte[] body = event.getSource();
        System.out.println("获取到延迟消息：" + new String(body));
    }

}
